package com.eliasbalasis.dwr4gwt.example;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

import org.directwebremoting.annotations.DataTransferObject;
import org.directwebremoting.annotations.RemoteProperty;


// identical structure with com.eliasbalasis.tibcopagebus4gwt.testsubscriber.client.PersonRepository

@DataTransferObject
public class PersonRepository {
	private String name;
	private Collection persons = new ArrayList();

	@RemoteProperty
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@RemoteProperty
	public Collection getPersons() {
		return persons;
	}
	public void setPersons(Collection persons) {
		this.persons = persons;
	}

	public String toString() {
		String s = "Name = "+getName()+"\n";
		if (getPersons()!=null) {
			Iterator persons = getPersons().iterator();
			int index = 0;
			while (persons.hasNext()) {
				Person person = (Person)persons.next();
				++index;
				s += "Person "+String.valueOf(index)+"\n"+person.toString();
			}
		}
		return s;
	}

}
